﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_ModifyPassword]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_ModifyPassword];
GO
CREATE PROCEDURE [dbo].[sproc_ModifyPassword]
    @UserName nvarchar(50),
    @OldPassword nvarchar(255),
    @NewPassword nvarchar(255)
/*

============================================================
功能:    修改用户密码
参数:
    @UserName nvarchar(50)        :    用户名
    @OldPassword nvarchar(255),        :    旧密码
    @NewPassword nvarchar(255)        :    新密码

============================================================

*/
AS
BEGIN
SET NOCOUNT ON

IF Exists(SELECT 1 FROM dbo.uds_staff WHERE Staff_Name = @UserName and [Password] = @OldPassword collate Latin1_General_CS_AS)
BEGIN
    UPDATE dbo.uds_staff SET [password] = @NewPassword WHERE staff_name = @UserName
    return 1;
END

-- Incorrect password, or the user does not exist.
return -1;

END
GO